#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" 窗体 """
from PIL import Image, ImageTk
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox


class FrameMainMenu:
    menuBar = None
    fileMenu = None
    editMenu = None

    def __init__(self):
        self.root = tk.Tk()
        self.initFrame()
        self.root.pack_slaves()
        self.root.mainloop()

    def initFrame(self):
        self.menuBar = tk.Menu(self.root)
        self.root.config(menu=self.menuBar)

        self.fileMenu = tk.Menu(self.menuBar)
        self.fileMenu.add_command(label="Exit", command=self.client_exit)
        self.menuBar.add_cascade(label="File", menu=self.fileMenu)

        self.editMenu = tk.Menu(self.menuBar)
        self.editMenu.add_command(label="Show Img", command=self.showImg)
        self.editMenu.add_command(label="Show Text", command=self.showText)
        self.menuBar.add_cascade(label="Edit", menu=self.editMenu)



    def showImg(self):
        load = Image.open("C:/Users/caiyuren/aface-client/faces/20171109224850.jpg")
        render = ImageTk.PhotoImage(load)
        img = tk.Label(self.root, image=render)
        img.image = render
        img.place(x=0, y=0)

    def showText(self):
        text = tk.Label(self.root, text="Hey there good lookin!")
        text.pack()

    def client_exit(self):
        exit()


if __name__ == '__main__':
    app = FrameMainMenu()
